#include <iostream>
#include <vector>
using namespace std;

int range_min(vector<int> &cache, int l, int r)
{
        if(l == r){
                return cache[l];
        }

        int mid = (l + r) >> 1;
        int lmin = range_min(cache, l, mid);
        int rmin = range_min(cache, mid + 1, r);
        return min(lmin, rmin);
}

void up(vector<int> &rmin, int i)
{
        rmin[i] = min(rmin[i << 1], rmin[(i << 1) + 1]);
}

void build(vector<int> &cache, vector<int> &rmin, int l, int r, int i)
{
        if(l == r){
                rmin[i] = cache[l];
        }else{
                int mid = (l + r) >> 1;
                build(cache, rmin, l, mid, (i << 1));
                build(cache, rmin, mid + 1, r, (i << 1) + 1);
                up(rmin, i);
        }
}

int query(vector<int> &rmin, int jobl, int jobr, int l, int r, int i)
{
        if(jobl <= l && r <= jobr){
                return rmin[i];
        }
        int mid = (l + r) >> 1;
        int l_min = INT32_MAX;
        int r_min = INT32_MAX;

        if(jobl <= mid){
                l_min = query(rmin, jobl, jobr, l, mid, i << 1);
        }
        if(mid < jobr){
                r_min = query(rmin, jobl, jobr, mid + 1, r, (i << 1) + 1);
        }
        return min(l_min, r_min);
}

int main()
{
        int m = 0, n = 0;
        cin >> m >> n;
        vector<int> cache(m + 1, 0);
        for(int i = 1; i <= m; i++){
                cin >> cache[i];
        }

        vector<int> rmin(m << 2, 0);
        build(cache, rmin, 1, m, 1);

        for(int i = 0, l, r; i < n; i++){
                cin >> l;
                cin >> r;
                //cout << range_min(cache, l, r) << ' ';
                cout << query(rmin, l, r, 1, m, 1) << ' ';
        }
        cout << '\n';

        return 0;
}